import Immutable from 'immutable'
import { REQUEST_POSTS, RECEIVE_POSTS } from '../Action/Index'
import { RECEIVE_SAVE, RECEIVE_REMOVE } from '../Action/Index'


export const asyncData = (state ={}, action = {}) => {
    if (action.type == REQUEST_POSTS) {
        return true
    } else {
        return false
    }
}

const defaultlState = Immutable.fromJS({})
export const fetchData = (state = defaultlState, action = {}) => {
    switch (action.type) {
        case RECEIVE_POSTS:
            return { type: action.type, data: action.json, isFetching: false };//返回一个新的state
        case RECEIVE_SAVE:
            return { type: action.type, data: action.json, isFetching: false };//返回一个新的state            
        case RECEIVE_REMOVE:
            return { type: action.type, data: action.json, isFetching: false };//返回一个新的state            
        default:
            return state
    }
}






